<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="../common/baseCss.jsp" %>
    <title>添加信息</title>
</head>
<body>
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="domainAddForm">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>数据名：
            </label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="数据名" id="dataName" name="dataName" >
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>数据key：
            </label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="数据key" id="dataKey" name="dataKey" >
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>数据值：
            </label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="数据值" id="dataValue" name="dataValue" >
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" id="info-save" name="info-save" >提交</button>
            </div>
        </div>
    </form>
</article>
<%@ include file="../common/baseJs.jsp" %>
<script type="text/javascript">
    var rootPath = getRootPath();
    $(function() {
        $("#info-save").click(function() {
            var dataName = $('#dataName').val();
            var dataKey = $('#dataKey').val();
            var dataValue = $('#dataValue').val();
            $.ajax({
                url:rootPath+"/addSiteInfo",
                type:"POST",
                data:{
                    "siteId" : "${siteId}",
                    "dataName":dataName,
                    "dataKey":dataKey,
                    "dataValue":dataValue,
                },
                success:function(data){
                    layer.msg('成功',{icon:1,time:1000},function() {
                        parent.window.location.href = rootPath + '/siteInfoPage?siteId=${siteId}';
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                },error: function () {
                    layer.alert("添加失败");
                }
            });
        })
    })
</script>
</body>
</html>